<?php

namespace app\system\controller;

use app\common\controller\Oauth;
use external\SFTools;

class Auth09 extends Oauth{

    public function initialize(){
        parent::initialize();
    }
    
    public function index() {
        return $this->fetch();
    }
    
    public function cw() {
        return $this->fetch();
    }
    
    /**
     * 导入Excel
     */
    public function importExcel() {
        $GoodsLogic = new \backend\logic\GoodsLogic();
        $result = $GoodsLogic->importExcel($this->userFind);
        return $result;
    }
    
    public function exportExcel() {
        if (!request()->isPost()) {
            $this->error(SFTools::err_msg('3301'));
            exit;
        }
        $data = input('post.');
        $keyword = htmlspecialchars($data['keyword']);
        $fStartDate = htmlspecialchars($data['fStartDate']);
        $fEndDate = htmlspecialchars($data['fEndDate']);
        $bc = htmlspecialchars($data['bc']);
        $fSupplierCode = htmlspecialchars($data['fSupplierCode']);
        $view = htmlspecialchars($data['view']);
    
        $goodsLogic = new \backend\logic\GoodsLogic;
        $result = $goodsLogic->exportExcel($keyword, $fStartDate, $fEndDate, $bc, $fSupplierCode, $view);
    
        if ($result === false) {
            $this->error(SFTools::err_msg('3601'));
            exit;
        }
    }
}
